﻿using System;
using System.Collections.Generic;
using System.Windows;
using Assist;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;

namespace YArchitech.HVAC
{
	[Transaction(TransactionMode.Manual)]
	public class cmdSpaceHighLight : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
		{
			UIApplication application = commandData.Application;
			Document document = application.ActiveUIDocument.Document;
			Selection selection = application.ActiveUIDocument.Selection;
			RevitVersionFuncs.ClearSelection(selection);
			FilteredElementCollector filteredElementCollector = new FilteredElementCollector(document);
			filteredElementCollector.OfCategory(BuiltInCategory.OST_MEPSpaces);
			int num = 0;
			List<Element> list = new List<Element>();
			foreach (Element item in filteredElementCollector)
			{
				num++;
				list.Add(item);
			}
			RevitVersionFuncs.SetSelection(selection, list);
			if (num == 0)
			{
				MessageBox.Show("当前文档没有空间。", "盈建科提示");
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
